The following description relates to generating a desired range of pseudo-random numbers (“PRNs”), for example, by mapping pseudo-random numbers to predefined or arbitrary number ranges.
Pseudo-random number generators (“PRNGs”) are an important part of modern computing, finding use in various applications including statistical simulations, generative modeling, cryptography and the Monte Carlo method for simulating physical systems. The capability to generate PRNs typically is a standard feature of most software programming environments.
Generating PRNs usually is implemented by one or more algorithms that generate a series of uncorrelated numbers, with each succeeding random number using the previous result as its seed. Thus, by knowing what the original seed is, along with the algorithm used, the same sequence of numbers can be re-generated in a predictable manner. The PRNs are considered pseudo-random, as opposed to truly random, because, even though they are deterministic based on the seed and algorithm used, the sequence of PRNs is relatively uncorrelated and appears random for most statistical tests. To that end, most PRNG algorithms produce numbers that tend to be uniformly distributed across a predetermined range of numbers, for example, between 0 and 231−1.
Common classes of PRNGs are linear congruential generators, lagged fibonacci generators, linear feedback shift registers and generalised feedback registers. More recent examples of PRNG's include Blum Blum Shub, Fortuna, and the Mersenne Twister. Each class of PRNG exhibits different properties, which generally relate to the quality of the PRNs that are generated. Typical of these classes of PRNGs is that the generated output range may not match what is desired or needed for some applications, such as picking random samples from a given range (e.g., picking 10 out of 1000 delivered goods for quality testing), which would require the generation of PRNs in a range 1, . . . , 1000. Typical PRNGs, however, generate PRNs in a range 0, . . . , 2b−1, where b is the bit length of a b-bit PRNG, for example, a 32-bit PRNG generates PRNs in a range 0, . . . , 232−1. The number of PRNs in such a range, i.e., the period, is 232−1.